package com.wgu.modules.service.impl;

import com.wgu.modules.dto.AddBookDTO;
import com.wgu.modules.mapper.AddBookMapper;
import com.wgu.modules.repository.BookRepository;
import com.wgu.modules.service.BookService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * @Author: w
 * @Date: 2019/7/3 17:10
 * @Version 1.0
 */
@Service
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class BookServiceImpl implements BookService {
    @Resource
    private BookRepository bookRepository;
    @Resource
    private AddBookMapper addBookMapper;

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void addBook(AddBookDTO bookDTO) {
        bookRepository.save(addBookMapper.toEntity(bookDTO));
    }
}
